import db from "../models/index.js";
import {getNow} from "../utils/utils.js";

let gupiaoUpdate = db.gupiao_update;
let gupiaoUpdateDao = {};

// 增加股票的修改记录
gupiaoUpdateDao.addGupiaoUpdate = function (user_id, gupiao_id, before_buy, before_sell_high, before_sell_low, t) {
  if (!t) {
    return gupiaoUpdate.create({
      user_id,
      gupiao_id,
      before_buy,
      before_sell_high,
      before_sell_low,
      update_time: getNow()
    });
  }
  return gupiaoUpdate.create({
    user_id,
    gupiao_id,
    before_buy,
    before_sell_high,
    before_sell_low,
    update_time: getNow()
  }, {transaction: t});
};

export default gupiaoUpdateDao;
